import { useState,useRef,useEffect } from "react"

const useSlide = (cb,direction) => {
    const domRef = useRef(null);

    const handleUp = (e) => {
        if(direction==='v'){
            cb(e.target.value);
            // console.log(e)
        }else if(direction==='h'){
            cb(e.target.value)
        }
    }

    useEffect(() => {
        domRef.current.addEventListener('mouseup',handleUp)
        return () => {
            domRef.current.removeEventListener('mouseup',handleUp)
        }
    },[])

    return {
        domRef
    }
}


export default useSlide